package com.rentong.common;

import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;
import org.apache.commons.lang3.RandomStringUtils;

/**
 * @author ZXY
 * @ClassName: TokenUtils
 * @Description:
 * @date 2017/6/30 17:11
 */
public class TokenUtils {
    private static final String privateKey = "9eec69f570eb91f%#$&()sdfsdx.1sfs317444073b3b1f936";

    /**
     * @Description: 生成令牌
     **/
    public static String getToken(String username) {
        return Hashing.goodFastHash(128).newHasher().putString(privateKey, Charsets.UTF_8).putString(username, Charsets.UTF_8).putString(RandomStringUtils.randomAlphanumeric(6), Charsets.UTF_8).hash().toString();
    }
}
